home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.1 KB  |  58 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #define    CURSES_LIBRARY    1
  4. #include <curses.h>
  5. #undef    PDC_debug
  6.  
  7. #ifdef PDCDEBUG
  8. char *rcsid__debug = "$Header: C:\CURSES\private\RCS\_debug.c 2.1 1993/06/18 20:22:26 MH Rel MH $";
  9. #endif
  10.  
  11.  
  12.     bool trace_on = FALSE;
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   PDC_debug()    - Write debugging info to log file.
  18.  
  19.   PDCurses Description:
  20.      This is a private PDCurses routine.
  21.  
  22.   PDCurses Return Value:
  23.      No return value.
  24.  
  25.   PDCurses Errors:
  26.      No errors are defined for this function.
  27.  
  28.   Portability:
  29.      PDCurses    void PDC_debug( char *,... );
  30.  
  31. **man-end**********************************************************************/
  32.  
  33. void    PDC_debug( char *fmt, ... )
  34. {
  35.     va_list args;
  36. FILE *dbfp;
  37. char buffer[256];
  38.  
  39. /*
  40.  * open debug log file append
  41. */
  42.     if (!trace_on)
  43.         return; 
  44.     dbfp = fopen("trace","a");
  45.     if (dbfp == NULL)
  46.     {
  47.         fprintf( stderr, "PDC_debug(): Unable to open debug log file\n" );
  48.         exit( 5 );
  49.     }
  50.  
  51.     va_start(args, fmt);
  52.     vsprintf(buffer,fmt,args);
  53.     fputs(buffer,dbfp);
  54.     va_end(args);
  55.     fclose(dbfp);
  56.     return;
  57. }
  58.